<template>
	<view class="back list">
		<view class="list-item back-white mt-2 item-between" v-for="(item, index) in orderAll.list" :key="index" @click="checkItem(item.status, item.id)">
			<view class="item">
				<image :src="item.img"></image>
			</view>
			<view class="item6 common-text-size" style="margin-left: calc(2vw);">
				<p><b>{{item.title}}</b>
					<text class="text-red" v-if="item.status == 2">点击确定收货</text>
					<text class="text-red" v-if="item.status == 0">点击可取消申请</text>
					<text class="text-red" v-if="item.status == 5">点击提交作业</text>
				</p>
				<view class="mt-2">
					<p class="inline-hidden ">订单号：{{item.orderNum}}</p>
					<p>手机号：{{item.phone}}</p>
					<view>
						<p class="float-l ml-2 mt-1 mb-1">
							<!-- 0：待审核，1：待发货，2：待收货，3：已完成，4：已关闭 -->
							<uni-tag type="error" inverted="true" circle="true" :text="tag[item.status]"></uni-tag>
						</p>
						<p class="font-color small-common-text-size float-r mr-4 mt-1 mb-1">合计：{{item.price}}</p>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uniTag from "@/components/uni-tag/uni-tag.vue"
	export default {
		components: {
			uniTag
		},
		props: {
			orderAll: {}
		},
		data() {
			return {
				tag: ['待审核', '待发货', '待收货', '已完成', '已关闭', "待提交", "已提交"]
			};
		},
		methods: {
			checkItem(status, id) {
				let _this = this;
				if (status == 5) {
					uni.showActionSheet({
						itemList: ["提交"],
						success(e) {
							if (e.tapIndex == 0) {
								uni.navigateTo({
									url: `/pages/homechild/chooseorder/workcommit/workcommit?orderId=${id}`
								})
							}
						},
					});
				}
				if (status == 2) {
					uni.showActionSheet({
						itemList: ["收货"],
						success(e) {
							if (e.tapIndex == 0) {
								_this.$http({
									url: `/order/update`,
									data: {
										goodsOrder: {
											id: id,
											status: 5
										},
										goodsLogistics: {}
									},
									method: "POST"
								}).then(response => {
									console.log(response);
									uni.startPullDownRefresh()
								});
							}
						},
					});
				}
				if (status == 0) {
					uni.showActionSheet({
						itemList: ["取消申请"],
						success(e) {
							if (e.tapIndex == 0) {
								_this.$http({
									url: `/order/update`,
									method: "POST",
									data: {
										goodsOrder: {
											id: id,
											status: 4
										},
										goodsLogistics: {}
									}
								}).then(res => {
									let data = res.data;
									uni.startPullDownRefresh()
									console.log(data);
								})
							}
						},
					});
				}
			}
		}
	}
</script>

<style>
	@import url("/static/css/common.css");

	.list-item {
		padding-top: calc(1vh);
	}

	.item>image {
		width: calc(30vw);
		height: calc(30vw);
	}

	.item6 {
		flex: 6;
		flex-direction: column;
	}

	.common-text-size {
		font-size: 4vw;
	}
</style>
